package org.bigdata.framework.core.protocol;

import java.util.HashMap;
import java.util.List;

import org.bigdata.framework.core.model.AnalysisTopic;
import org.bigdata.framework.core.model.AnalysisTopicPermission;
import org.bigdata.framework.core.model.AnalysisTopicTarget;
import org.bigdata.framework.core.model.BaikeCategory;
import org.bigdata.framework.core.service.IAnalysisTopicPermissionService;
import org.bigdata.framework.core.service.IAnalysisTopicService;
import org.bigdata.framework.core.service.IAnalysisTopicTargetService;
import org.bigdata.framework.core.utils.MybatisPlusTools;
import org.springframework.beans.factory.annotation.Autowired;

import com.baomidou.mybatisplus.plugins.Page;

public class AnalysisService implements IAnalysisService {
	
	@Autowired
	private IAnalysisTopicTargetService analysisTopicTargetService;
	@Autowired
	private IAnalysisTopicService analysisTopicService;
	@Autowired
	private IAnalysisTopicPermissionService analysisTopicPermissionService;

	@Override
	public AnalysisTopic saveAnalysisTopic(AnalysisTopic analysisTopic) {
		boolean r = analysisTopicService.insert(analysisTopic);
		if (r) {
			return analysisTopic;
		}
		return null;
	}

	@Override
	public AnalysisTopic editAnalysisTopic(AnalysisTopic analysisTopic) {
		boolean r = analysisTopicService.updateAllColumnById(analysisTopic);
		if (r) {
			return analysisTopic;
		}
		return null;
	}

	@Override
	public void deleteAnalysisTopic(AnalysisTopic analysisTopic) {
		boolean r = analysisTopicService.deleteById(analysisTopic.getId());
		if (r) {
			System.out.println("analysisTopic 删除成功>>>" + analysisTopic.getId());
		}

	}

	@Override
	public AnalysisTopic findAnalysisTopic(Integer id) {
		
		return analysisTopicService.selectById(id);
	}

	@Override
	public List<AnalysisTopic> getAnalysisTopic() {
		
		return analysisTopicService.selectList(null);
	}

	@Override
	public List<AnalysisTopic> getAnalysisTopic(
			HashMap<String, Object> queryParams, int pageNumber, int pageSize) {
		return analysisTopicService.selectPage(
				new Page<AnalysisTopic>(pageNumber, pageSize),
				new MybatisPlusTools<AnalysisTopic>().getEwByList(queryParams))
				.getRecords();
	}

	@Override
	public Integer getAnalysisTopicCount(HashMap<String, Object> queryParams) {
		return analysisTopicService.selectCount(new MybatisPlusTools<AnalysisTopic>()
				.getEwByCount(queryParams));
	}

	@Override
	public AnalysisTopicTarget saveAnalysisTopicTarget(
			AnalysisTopicTarget analysisTopicTarget) {
		boolean r = analysisTopicTargetService.insert(analysisTopicTarget);
		if (r) {
			return analysisTopicTarget;
		}
		return null;
	}

	@Override
	public AnalysisTopicTarget editAnalysisTopicTarget(
			AnalysisTopicTarget analysisTopicTarget) {
		boolean r = analysisTopicTargetService.updateAllColumnById(analysisTopicTarget);
		if (r) {
			return analysisTopicTarget;
		}
		return null;
	}

	@Override
	public void deleteAnalysisTopicTarget(
			AnalysisTopicTarget analysisTopicTarget) {
		boolean r = analysisTopicTargetService.deleteById(analysisTopicTarget.getId());
		if (r) {
			System.out.println("analysisTopicTarget 删除成功>>>" + analysisTopicTarget.getId());
		}

	}

	@Override
	public AnalysisTopicTarget findAnalysisTopicTarget(Integer id) {
		
		return analysisTopicTargetService.selectById(id);
	}

	@Override
	public List<AnalysisTopicTarget> getAnalysisTopicTarget(
			HashMap<String, Object> queryParams, int pageNumber, int pageSize) {
		return analysisTopicTargetService.selectPage(
				new Page<AnalysisTopicTarget>(pageNumber, pageSize),
				new MybatisPlusTools<AnalysisTopicTarget>().getEwByList(queryParams))
				.getRecords();
	}

	@Override
	public Integer getAnalysisTopicTargetCount(HashMap<String, Object> queryParams) {
		return analysisTopicTargetService.selectCount(new MybatisPlusTools<AnalysisTopicTarget>()
				.getEwByCount(queryParams));
	}

	@Override
	public AnalysisTopicPermission saveAnalysisTopicPermission(
			AnalysisTopicPermission analysisTopicPermission) {
		boolean r = analysisTopicPermissionService.insert(analysisTopicPermission);
		if (r) {
			return analysisTopicPermission;
		}
		return null;
	}

	@Override
	public AnalysisTopicPermission editAnalysisTopicPermission(
			AnalysisTopicPermission analysisTopicPermission) {
		boolean r = analysisTopicPermissionService.updateAllColumnById(analysisTopicPermission);
		if (r) {
			return analysisTopicPermission;
		}
		return null;
	}

	@Override
	public void deleteAnalysisTopicPermission(
			AnalysisTopicPermission analysisTopicPermission) {
		boolean r = analysisTopicPermissionService.deleteById(analysisTopicPermission.getId());
		if (r) {
			System.out.println("analysisTopicPermission 删除成功>>>" + analysisTopicPermission.getId());
		}

	}

	@Override
	public AnalysisTopicPermission findAnalysisTopicPermission(String id) {
		
		return analysisTopicPermissionService.selectById(id);
	}

	@Override
	public List<AnalysisTopicPermission> getAnalysisTopicPermission(
			HashMap<String, Object> queryParams, int pageNumber, int pageSize) {
		return analysisTopicPermissionService.selectPage(
				new Page<AnalysisTopicPermission>(pageNumber, pageSize),
				new MybatisPlusTools<AnalysisTopicPermission>().getEwByList(queryParams))
				.getRecords();
	}

	@Override
	public Integer getAnalysisTopicPermissionCount(
			HashMap<String, Object> queryParams) {
		return analysisTopicPermissionService.selectCount(new MybatisPlusTools<AnalysisTopicPermission>()
				.getEwByCount(queryParams));
	}

}
